<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
	<title>Pesquisa Processo</title>
</h:head>
<ui:composition template="templatePrincipal.xhtml">
	<ui:define name="header">
		<ui:include src="header.xhtml" />
	</ui:define>
	<ui:define name="centro">
		<h:body>
			<p:growl id="messages" showDetail="true" life="1000" />
			<h:form id="form1">
				<p:panel header="Dados para pesquisa">
					<p:toolbar>
						<p:toolbarGroup align="left">
							<p:commandButton id="pesqprocessobnt2" value="Pesquisar Processo"
								actionListener="#{processoController.pesquisaProcesso}"
								update="form1:tabview1:dataTable,checkListoutp,selecionaProcesso"
								icon="ui-icon-search" />
							<p:commandButton id="salvaprocessobnt2" value="Salvar Processo"
								actionListener="#{processoController.salvarProcesso}"
								update="form1:tabview1:dataTable,:messages" icon="ui-icon-disk" />
							<p:commandButton id="imprimirCapaBnt2" value="Imprimir Capa"
								actionListener="#{processoController.imprimeCapa}" ajax="false"
								icon="ui-icon-print" />
							<p:commandButton id="imprimirbnt2" value="Imprimir Pendencias"
								actionListener="#{processoController.imprimePendencias}"
								ajax="false" icon="ui-icon-print" />
							<p:commandButton id="calculacusto" value="Calcula Custo"
								actionListener="#{processoController.calculaCusto}"
								update="form1:tabview1" icon="ui-icon-circle-check" />
						</p:toolbarGroup>
					</p:toolbar>
					<p:outputLabel for="pesqproponente" value="Proponente : " />
					<p:autoComplete id="pesqproponente"
						value="#{processoController.selectedCliente}"
						completeMethod="#{processoController.completeCliente}"
						var="cliente" itemLabel="#{cliente.proponente}"
						itemValue="#{cliente}" converter="clienteConverter" />
					<h:outputText value="Processo : " />
					<p:selectOneMenu value="#{processoController.processo}"
						converter="processoConverter" id="selecionaProcesso">
						<f:selectItems value="#{processoController.listaProcessos}"
							var="processo" itemLabel="#{processo.tituloProcesso}"
							itemValue="#{processo}" />
						<p:ajax update="form1:tabview1:dataTable,checkListoutp"
							listener="#{processoController.trocaProcesso}" />
					</p:selectOneMenu>
				</p:panel>
				<p:outputPanel id="checkListoutp">
					<p:tabView id="tabview1" dynamic="true" cache="false"
						rendered="#{processoController.processoRendered}">
						<p:tab id="tabgeral" title="Dados Gerais do Processo">
							<p:panel header="Cliente">
								<p:panelGrid>
									<f:facet name="header">
										<p:row>
											<p:column> Proponente </p:column>
											<p:column> CPF </p:column>
											<p:column> Conjugê </p:column>
											<p:column> Residência </p:column>
											<p:column> Tel. Celular </p:column>
											<p:column> Tel. Residencial </p:column>
											<p:column> Tel. Celular Conj. </p:column>
											<p:column> Tel. Residencial Conj. </p:column>
											<p:column> Tel. Comercial Conj. </p:column>
										</p:row>
									</f:facet>
									<p:row>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.proponente}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.cpf}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.conjuge}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.cpfConjuge}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.residencia}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.telCelular}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.telComercial}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.telCelularConj}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.capaProcesso.cliente.telComercialConj}">
											</h:outputText>
										</p:column>
									</p:row>
								</p:panelGrid>
							</p:panel>
							<p:panel header="Vendedor" id="pvendedor">
								<f:facet name="header">
									<p:outputLabel for="pesqvendedor" value="Vendedor : " />
									<p:autoComplete id="pesqvendedor"
										value="#{processoController.processo.vendedor}"
										completeMethod="#{processoController.completeVendedor}"
										var="vendedor" itemLabel="#{vendedor.nome}"
										itemValue="#{vendedor}" converter="vendedorConverter">
										<p:ajax update="pvendedor"
											listener="#{processoController.atualizaCapa}" />
									</p:autoComplete>
								</f:facet>
								<p:panelGrid>
									<f:facet name="header">
										<p:row>
											<p:column> Nome </p:column>
											<p:column> CPF </p:column>
											<p:column> Telefone </p:column>
											<p:column> Conjugê </p:column>
											<p:column> CPF Conjugê </p:column>
											<p:column> Tel. Conjugê </p:column>
											<p:column> Email-1 </p:column>
											<p:column> TEmail-2 </p:column>
										</p:row>
									</f:facet>
									<p:row>
										<p:column>
											<h:outputText
												value="#{processoController.processo.vendedor.nome}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.vendedor.cpf}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.vendedor.tel}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.vendedor.nomeConjuge}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.vendedor.cpfConjuge}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.vendedor.telConjuge}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.vendedor.email1}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.vendedor.email2}">
											</h:outputText>
										</p:column>
									</p:row>
								</p:panelGrid>
							</p:panel>
							<p:panel header="Corretor" id="pcorretor">
								<f:facet name="header">
									<p:outputLabel for="pesqcorretor" value="Corretor : " />
									<p:autoComplete id="pesqcorretor"
										value="#{processoController.processo.corretor}"
										completeMethod="#{processoController.completeCorretor}"
										var="corretor" itemLabel="#{corretor.nome}"
										itemValue="#{corretor}" converter="corretorConverter">
										<p:ajax update="pcorretor"
											listener="#{processoController.atualizaCapa}" />
									</p:autoComplete>
								</f:facet>
								<p:panelGrid>
									<f:facet name="header">
										<p:row>
											<p:column> Corretor </p:column>
											<p:column> Imobiliária </p:column>
											<p:column> Telefone Imobiliária </p:column>
											<p:column> elefone Corretor </p:column>
											<p:column> Email </p:column>
										</p:row>
									</f:facet>
									<p:row>
										<p:column>
											<h:outputText
												value="#{processoController.processo.corretor.nome}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.corretor.imobiliaria}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.corretor.telImobiliaria}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.corretor.tel}">
											</h:outputText>
										</p:column>
										<p:column>
											<h:outputText
												value="#{processoController.processo.corretor.email}">
											</h:outputText>
										</p:column>
									</p:row>
								</p:panelGrid>
							</p:panel>
						</p:tab>
						<p:tab id="tabimovel" title="Dados do Imovel">
							<p:panelGrid>
								<f:facet name="header">
									<p:row>
										<p:column> Endereço </p:column>
										<p:column> Mat. </p:column>
										<p:column> Rec. Próprios. </p:column>
										<p:column> Fnd. Garantia </p:column>
										<p:column> Val. Financ </p:column>
										<p:column> Val. Avaliação </p:column>
										<p:column> Gar. </p:column>
										<p:column> Val.Vnd. Gar. </p:column>
										<p:column> Val. Vnd Apto. </p:column>
										<p:column> Val. Vnd Total </p:column>
									</p:row>
								</f:facet>
								<p:row>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.endereco}"
											size="20" />
									</p:column>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.matricula}"
											size="5" />
									</p:column>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.recursosprop}"
											size="10" />
									</p:column>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.fundogarantia}"
											size="10" />
									</p:column>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.valorfinanc}"
											size="10" />
									</p:column>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.valoraval}"
											size="10" />
									</p:column>
									<p:column>
										<p:selectBooleanCheckbox
											value="#{processoController.processo.imovel.garagem}" />
									</p:column>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.valorcompvendagaragem}"
											size="10" />
									</p:column>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.valcompvendaapto}"
											size="10" />
									</p:column>
									<p:column>
										<p:inputText
											value="#{processoController.processo.imovel.valcompvendatotal}"
											size="10" />
									</p:column>
								</p:row>
							</p:panelGrid>
						</p:tab>
						<p:tab id="tabcusto" title="Custo do Processo">
							<p:panel>
								<p:panelGrid>
									<f:facet name="header">
										<p:row>
											<p:column colspan="7"> Base de Calculo </p:column>
										</p:row>
										<p:row>
											<p:column> Taxa de ITBI </p:column>
											<p:column> Valor da matricula  </p:column>
											<p:column> Taxa de CCFGTS </p:column>
											<p:column> Taxa de CCSBTE </p:column>
											<p:column> Valor do P. Seguro </p:column>
											<p:column> Valor da Pesquisa Cadastral </p:column>
											<p:column> Valor do Despachante </p:column>
										</p:row>
									</f:facet>
									<p:row>
										<p:column>
											<p:inputText id="itbi"
												value="#{processoController.processo.custo.paramibti}"
												label="itbi" />
										</p:column>
										<p:column>
											<p:inputText id="matricula"
												value="#{processoController.processo.custo.paramvmatricula}"
												label="matricula" />
										</p:column>
										<p:column>
											<p:inputText id="ccfgts"
												value="#{processoController.processo.custo.paramtxccfgts}"
												label="ccfgts" />
										</p:column>
										<p:column>
											<p:inputText id="ccsbte"
												value="#{processoController.processo.custo.paramtxccsbte}"
												label="ccsbte" />
										</p:column>
										<p:column>
											<p:inputText id="seguro"
												value="#{processoController.processo.custo.parampremioseguro}"
												label="seguro" />
										</p:column>
										<p:column>
											<p:inputText id="pesqcad"
												value="#{processoController.processo.custo.parampesqcadastral}"
												label="pesqcad" />
										</p:column>
										<p:column>
											<p:inputText id="despachante"
												value="#{processoController.processo.custo.paramdesp}"
												label="despachante" />
										</p:column>
									</p:row>
								</p:panelGrid>
							</p:panel>
							<p:panel>
								<p:panelGrid>
									<f:facet name="header">
										<p:row>
											<p:column colspan="6"> Custo Detalhado </p:column>
										</p:row>
										<p:row>
											<p:column> Cartório de notas </p:column>
											<p:column> Cartório de retistro de imóveis  </p:column>
											<p:column> Custo ITBI </p:column>
											<p:column> Custo Caixa </p:column>
											<p:column> Custo Despachante </p:column>
											<p:column> Custo Total </p:column>
										</p:row>
									</f:facet>
									<p:row>
										<p:column>
											<p:inputText id="cnotas"
												value="#{processoController.processo.custo.custocnotas}"
												label="cnotas" />
										</p:column>
										<p:column>
											<p:inputText id="cri"
												value="#{processoController.processo.custo.custocri}"
												label="cri" />
										</p:column>
										<p:column>
											<p:inputText id="custoitbi"
												value="#{processoController.processo.custo.cusoibti}"
												label="custoitbi" />
										</p:column>
										<p:column>
											<p:inputText id="custocaixa"
												value="#{processoController.processo.custo.custocaixa}"
												label="custocaixa" />
										</p:column>
										<p:column>
											<p:inputText id="custodesp"
												value="#{processoController.processo.custo.custodesp}"
												label="custodesp" />
										</p:column>
										<p:column>
											<p:inputText id="custototal"
												value="#{processoController.processo.custo.custototal}"
												label="custototal" />
										</p:column>
									</p:row>
								</p:panelGrid>
							</p:panel>
						</p:tab>
						<p:tab id="tabcapa" title="Fluxo do Processo">
							<h:panelGrid columns="1" cellpadding="5">
								<!-- <p:fieldset legend="Cliente" toggleable="true" toggleSpeed="500" style="width:50%"> -->

								<p:panel header="Andamento de Processo">
									<p:accordionPanel
										value="#{processoController.capaProcesso.passosPorGrupo}"
										var="andamentoItem">
										<p:tab title="#{andamentoItem.grupo}">
											<p:dataGrid var="andamento"
												value="#{andamentoItem.acompanhaLines}" columns="3"
												rows="12">

												<p:panel
													style="height:120px;background:url(/resources/images/postit.jpg)"
													header="#{andamento.passo}">
												</p:panel>
											</p:dataGrid>
										</p:tab>
									</p:accordionPanel>
								</p:panel>
							</h:panelGrid>
						</p:tab>
						<p:tab id="tabchk" title="Check List">
							<p:panel header="#{processoController.processo.pchkheader.titulo}"
								id="dataTable">
								<p:accordionPanel value="#{processoController.chklistPerGroup}"
									var="chkitem">
									<p:tab title="#{chkitem.group}">
										<h:panelGrid>
											<p:dataTable id="dataTablechk" var="chkline"
												value="#{chkitem.checkListItems}"
												selection="#{processoController.selectedChkLine}"
												selectionMode="single" rowKey="#{chkline.processChk_id}">
												<p:column>
													<f:facet name="header">
														<h:outputText value="Descrição" />
													</f:facet>
													<h:outputText value="#{chkline.descricao}" />
												</p:column>
												<p:column>
													<f:facet name="header">
														<h:outputText value="Verificado" />
													</f:facet>
													<p:selectBooleanCheckbox value="#{chkline.checked}">

														<p:ajax event="change"
															listener="#{processoController.changeValue}" />

													</p:selectBooleanCheckbox>
												</p:column>
												<p:column>
													<f:facet name="header">
														<h:outputText value="Opicional" />
													</f:facet>
													<p:selectBooleanCheckbox value="#{chkline.opcional}">

														<p:ajax event="change"
															listener="#{processoController.changeValue}" />


													</p:selectBooleanCheckbox>
												</p:column>
												<p:column>
													<f:facet name="header">
														<h:outputText value="Comentário" />
													</f:facet>
													<p:inputText value="#{chkline.comentario}">
														<p:ajax event="change"
															listener="#{processoController.changeValue}" />
													</p:inputText>
												</p:column>

											</p:dataTable>
										</h:panelGrid>
									</p:tab>
								</p:accordionPanel>
							</p:panel>
							<p:panel header="Observações">
								<p:inputTextarea id="p_observacoes" rows="10" cols="100"
									value="#{processoController.processo.observacoes}" />

								<p:commandButton id="salvaprocessobnt" value="Salvar Processo"
									actionListener="#{processoController.salvarProcesso}"
									update="dataTable,:messages" />

								<p:commandButton id="imprimirbnt" value="Imprimir Pendencias"
									actionListener="#{processoController.imprimePendencias}"
									ajax="false" />

								<p:commandButton id="imprimirCapaBnt" value="Imprimir Capa"
									actionListener="#{processoController.imprimeCapa}" ajax="false" />


							</p:panel>
						</p:tab>
						<p:tab id="tabacomp" title="Acompanhamento">
							<p:dataTable id="dataTableacomp" var="acompline"
								value="#{processoController.processo.acompanhaLines}"
								selection="#{processoController.selectedAcompLine}"
								selectionMode="single" rowKey="#{acompline.data}">
								<p:column>
									<f:facet name="header">
										<h:outputText value="Data" />
									</f:facet>
									<p:calendar value="#{acompline.data}" mode="popup"
										showOn="button" />
								</p:column>
								<p:column>
									<f:facet name="header">
										<h:outputText value="Descrição" />
									</f:facet>
									<p:inputText value="#{acompline.passo}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Etapa" />
									</f:facet>
									<p:selectOneMenu value="#{acompline.gpassos}"
										converter="grupoPassosConverter" id="selecionaGPasso">
										<f:selectItems value="#{processoController.listaGPassos}"
											var="grupo_passo" itemLabel="#{grupo_passo.titulo}"
											itemValue="#{grupo_passo}" />

										<p:ajax update="selecionaPasso" />
									</p:selectOneMenu>
								</p:column>
								<p:column>
									<f:facet name="header">
										<h:outputText value="Passo da Etapa" />
									</f:facet>
									<p:selectOneMenu value="#{acompline.passos}"
										converter="passosConverter" id="selecionaPasso">
										<f:selectItems value="#{acompline.gpassos.passos}" var="passo"
											itemLabel="#{passo.descricao}" itemValue="#{passo}" />
									</p:selectOneMenu>
								</p:column>
							</p:dataTable>
							<p:commandButton id="inserePassobnt" value="Insere Passo"
								actionListener="#{processoController.inserePasso}"
								update="dataTableacomp,:messages" />
							<p:commandButton id="removePassobnt" value="Remove Passo"
								actionListener="#{processoController.removePasso}"
								update="dataTableacomp,:messages" />
						</p:tab>
					</p:tabView>
				</p:outputPanel>
			</h:form>
		</h:body>
	</ui:define>
</ui:composition>
</html>